package com.jason.lucene.example.index;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.junit.Test;

import java.util.Random;

/**
 * @author he peng
 * @create 2017/11/30 17:15
 * @see
 */
public class DocumentBoostTest extends BaseIndexingTest {

    @Test
    public void boost() throws Exception {

        String[] emails = {"qq.com" , "163.com"};
        Random random = new Random();
        IndexWriterConfig conf = new IndexWriterConfig(getAnalyzer());
        IndexWriter indexWriter = new IndexWriter(super.indexDir, conf);
        for (int i = 0 ; i < 100 ; i++ ) {
            int e = random.nextInt(2);
            Document doc = new Document();
            doc.add(new TextField("senderEmail", emails[e], TextField.Store.YES));
            doc.add(new Field("senderName" , "" , TextField.TYPE_STORED));
            doc.add(new Field("subject" , "" , TextField.TYPE_STORED));
            doc.add(new Field("body" , "" , TextField.TYPE_NOT_STORED));
            if (e == 0) {

            } else {

            }

        }
    }
}
